package com.bjdd.jdy.util;


import com.bjdd.jdy.base.BaseResult;
import com.bjdd.jdy.entity.BankBean;
import com.bjdd.jdy.entity.BankCardBean;
import com.bjdd.jdy.entity.ExamResult;
import com.bjdd.jdy.entity.FeedBack;
import com.bjdd.jdy.entity.HotMapBean;
import com.bjdd.jdy.entity.NewsBean;
import com.bjdd.jdy.entity.OrderBean;
import com.bjdd.jdy.entity.OrderResult;
import com.bjdd.jdy.entity.PayBean;
import com.bjdd.jdy.entity.ProvinceBean;
import com.bjdd.jdy.entity.ResourceUrlBean;
import com.bjdd.jdy.entity.TokenResult;
import com.bjdd.jdy.entity.ToolBean;
import com.bjdd.jdy.entity.User;
import com.bjdd.jdy.entity.result.AcountResult;
import com.bjdd.jdy.entity.InfoBean;
import com.bjdd.jdy.entity.result.PerformanceResult;
import com.bjdd.jdy.entity.result.TodayDataResult;

import java.util.List;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import rx.Observable;


/**
 * Created by Administrator on 2016/3/23.
 */
public interface ApiService {

    /**
     * 登录接口
     *
     * @param mobile
     * @param pwd
     * @return
     */
    @POST("carrier/users/auth/login")
    Observable<BaseResult<TokenResult>> login(@Query("mobile") String mobile, @Query("pwd") String pwd, @Query("timestamp") String timestamp, @Query("sign") String sign);

    /**
     * 获取验证码
     * @param phone
     */
    @GET("carrier/users/auth/register/code")
    Observable<BaseResult<String>> code(@Query("mobile") String phone,@Query("timestamp") String timestamp,@Query("sign") String sign);

    /**
     * 注册接口
     * @param code
     * @param phone
     * @param pwd
     * @return
     */
    @POST("carrier/users/auth/register")
    Observable<BaseResult<TokenResult>> register(@Query("mobile") String phone,@Query("pwd") String pwd,@Query("code") String code,@Query("timestamp") String timestamp,@Query("sign") String sign);

    /**
     * 获取用户信息
     * @return
     */
    @GET("carrier/info/{carrierId}")
    Observable<BaseResult<User>> getUserInfo(@Header("Authorization") String token,@Path("carrierId") String carrierId);

    /**
     * 忘记密码获取验证码
     * @param mobile
     * @param timestamp
     * @param sign
     * @return
     */
    @GET("carrier/users/auth/forget/code")
    Observable<BaseResult<String>> getForgetCode(@Query("mobile") String mobile,@Query("timestamp") String timestamp,@Query("sign") String sign);

    /**
     * 修改密码
     * @param mobile
     * @param pwd
     * @param code
     * @param timestamp
     * @param sign
     * @return
     */
    @POST("carrier/users/auth/codeModify")
    Observable<BaseResult<String>> resetPwd(@Query("mobile") String mobile,@Query("pwd") String pwd,@Query("code") String code,@Query("timestamp") String timestamp,@Query("sign") String sign);

    /**
     * 登陆获取验证码
     * @param mobile
     * @param timestamp
     * @param sign
     * @return
     */
    @GET("carrier/users/auth/codeLogin/code")
    Observable<BaseResult<String>> getLoginCode(@Query("mobile") String mobile,@Query("timestamp")String timestamp,@Query("sign")String sign);

    /**
     * 快捷登陆
     * @param mobile
     * @param timestamp
     * @param code
     * @param sign
     * @return
     */
    @POST("carrier/users/auth/codeLogin")
    Observable<BaseResult<TokenResult>> codeLogin(@Query("mobile")String mobile,@Query("timestamp")String timestamp,@Query("code")String code,@Query("sign")String sign);

    /**
     * 提交身份资料审核
     * @param token
     * @param map
     * @param photos
     * @return
     */
    @Multipart
    @POST("carrier/info/upload")
    Observable<BaseResult<String>> submitInfo(@Header("Authorization") String token, @QueryMap Map<String,String> map,@PartMap Map<String,RequestBody> photos);

    /**
     * 获取开通地区列表
     * @param token
     * @return
     */
    @GET("carrier/info/area")
    Observable<BaseResult<List<ProvinceBean>>> getArea(@Header("Authorization") String token);

    /**
     * 获取交通工具
     * @param token
     * @return
     */
    @GET("carrier/info/tools")
    Observable<BaseResult<List<ToolBean>>> getTools(@Header("Authorization") String token);

    /**
     * 获取考题
     * @param token
     * @param carrierId
     * @return
     */
    @POST("carrier/exams")
    Observable<BaseResult<ExamResult>> getExam(@Header("Authorization") String token, @Query("carrierId")String carrierId);



    /**
     * 提交考试通过
     * @param token
     * @param carrierId
     * @param chapter  通过阶段
     * @return
     */
    @PUT("carrier/exams/{chapter}")
    Observable<BaseResult<String>> passExam(@Header("Authorization") String token,@Path("chapter")int chapter,@Query("carrierId") String carrierId);

    /**
     * 上传自由人经纬度
     * @param token
     * @param carrierId
     * @param lng
     * @param lat
     * @return
     */
    @POST("carrier/locations")
    Observable<BaseResult<String>> locations(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("lng")double lng,@Query("lat")double lat);

    /**
     * 意见反馈
     * @param token
     * @param feedback
     * @return
     */
    @POST("carrier/feedback")
    Observable<BaseResult<String>> feedback(@Header("Authorization") String token, @Body FeedBack feedback,@Query("content")String content,@Query("userId")String userId);

    /**
     * 开工
     * @param token
     * @param carrierId
     * @return
     */
    @PUT("carrier/users/start/{carrierId}")
    Observable<BaseResult<String>> start(@Header("Authorization") String token,@Path("carrierId") String carrierId);
    /**
     * 收工
     * @param token
     * @param carrierId
     * @return
     */
    @PUT("carrier/users/stop/{carrierId}")
    Observable<BaseResult<String>> stop(@Header("Authorization") String token,@Path("carrierId") String carrierId);

    /**
     * 获取订单列表
     * @param token
     * @param page
     * @param size
     * @param sort
     * @param dir
     * @return
     */
    @GET("orders/waitPair")
    Observable<BaseResult<OrderResult>> waitPair(@Header("Authorization") String token, @Query("page") int page, @Query("size")int size, @Query("sort")String sort, @Query("dir")String dir);

    /**
     * 抢单
     * @param token
     * @param carrierId
     * @param orderId
     * @return
     */
    @PUT("orders/grab")
    Observable<BaseResult<String>> grba(@Header("Authorization") String token,@Query("carrierId") String carrierId,@Query("orderId")long orderId);

    /**
     * 获取今日收益，工作时长
     * @param token
     * @param carrierId
     * @return
     */
    @GET("carrier/users/todayData/{carrierId}")
    Observable<BaseResult<TodayDataResult>> todayData(@Header("Authorization") String token,@Path("carrierId") String carrierId);

    /**
     * 自由人订单查询
     * @param token
     * @param carrierId
     * @param page
     * @param size
     * @return
     */
    @GET("orders/queryOrders")
    Observable<BaseResult<OrderResult>> queryOrders(@Header("Authorization") String token,@Query("carrierId") String carrierId,@Query("status")int type,@Query("page")int page,@Query("size")int size);

    /**
     * 可抢订单查询
     * @param token
     * @param page
     * @param size
     * @return
     */
    @GET("orders/queryWaitOrder")
    Observable<BaseResult<OrderResult> > queryWaitOrder(@Header("Authorization") String token,@Query("page")int page,@Query("cityName")String cityName,@Query("size")int size);

    /**
     * 拍照验货
     * @param token
     * @param carrierId
     * @param orderNo
     * @param photos
     * @return
     */
    @Multipart
    @POST("orders/pickup")
    Observable<BaseResult<String>> pickup(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("orderNo")String orderNo,@PartMap Map<String,RequestBody> photos);

    /**
     * 确认收货
     * @param token
     * @param sign
     * @param orderNo
     * @param carrierId
     * @param code
     * @return
     */
    @PUT("orders/signOrder")
    Observable<BaseResult<String>> signOrder(@Header("Authorization") String token,@Query("sign")String sign,@Query("orderNo")String orderNo,@Query("carrierId")String carrierId,@Query("code")String code);

    /**
     * 获取订单详情
     * @param token
     * @param orderNo
     * @return
     */
    @GET("orders/auth/{orderNo}")
    Observable<BaseResult<OrderBean>> orderDetail(@Header("Authorization") String token,@Path("orderNo")String orderNo);

    /**
     * 发送订单验证，短信验证码
     * @param token
     * @param orderNo
     * @param carrierId
     * @return
     */
    @PUT("orders/sendSMSCode")
    Observable<BaseResult<String>> sendSMSCode(@Header("Authorization") String token,@Query("orderNo") String orderNo,@Query("carrierId")String carrierId);

    /**
     * 获取个人信息评价和单数
     * @param token
     * @param carrierId
     * @return
     */
    @GET("carrier/users/performance/{carrierId}")
    Observable<BaseResult<PerformanceResult>>performance(@Header("Authorization") String token,@Path("carrierId")String carrierId);

    /**
     * 获取支付二维码
     * @param token
     * @param orderNo
     * @return
     */
    @PUT("pay/cod")
    Observable<BaseResult<String>> cod(@Header("Authorization") String token,@Query("orderNo") String orderNo);

    /**
     * 获取交易记录
     * @param token
     * @param carrierId
     * @param page
     * @param size
     * @return
     */
    @GET("carrier/users/account/{carrierId}")
    Observable<BaseResult<AcountResult>> acount(@Header("Authorization") String token, @Path("carrierId")String carrierId, @Query("page")int page, @Query("size")int size);

    /**
     * 获取银行卡
     * @param token
     * @param carrierId
     * @return
     */
    @GET("carrier/users/bankCards/{carrierId}")
    Observable<BaseResult<List<BankCardBean>>> bankCards(@Header("Authorization") String token,@Path("carrierId") String carrierId);

    /**
     * 删除银行卡
     * @param token
     * @param carrierId
     * @param cardId
     * @return
     */
    @PUT("carrier/users/bankCards/close")
    Observable<BaseResult<String>> delBankCard(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("bankCardId")String cardId);

    /**
     * 获取银行列表
     * @return
     */
    @GET("banks")
    Observable<BaseResult<List<BankBean>>> getBanks(@Header("Authorization") String token);

    /**
     * 绑定银行卡
     * @param token
     * @param carrierId
     * @param bankcard
     * @param realname
     * @param bankId
     * @return
     */
    @POST("carrier/users/bankCardVerify")
    Observable<BaseResult<String>> bindBankCard(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("bankcard")String bankcard,@Query("realname")String realname,@Query("bankId")String bankId);

    /**
     * 提现
     * @param token
     * @param carrierId
     * @param bankCardId
     * @param money
     * @return
     */
    @PUT("carrier/users/bankCardWithdraw")
    Observable<BaseResult<String>> withDraw(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("bankCardId")String bankCardId,@Query("money")String money);

    /**
     * 获取所有订单
     * @param token
     * @param carrierId
     * @param page
     * @param size
     * @return
     */
    @GET("orders/carrierOrder")
    Observable<BaseResult<List<OrderBean>>> orders(@Header("Authorization") String token,@Query("carrierId")String carrierId,@Query("page")int page,@Query("size")int size);

    /**
     * 获取个人信息
     * @param token
     * @param carrierId
     * @return
     */
    @GET("carrier/users/info/{carrierId}")
    Observable<BaseResult<InfoBean>> info(@Header("Authorization") String token,@Path("carrierId") String carrierId);

    /**
     * 二维码签收
     * @param token
     * @param orderId
     * @return
     */
    @GET("orders/qrCodeSign")
    Observable<BaseResult<String>> qrCodeSign(@Header("Authorization") String token,@Query("orderId")String orderId);

    /**
     * 上传用户头像
     * @param token
     * @param carrierId
     * @param head
     * @return
     */
    @Multipart
    @PUT("carrier/info/headPhoto")
    Observable<BaseResult<User>> headPhoto(@Header("Authorization") String token,@Query("carrierId") String carrierId,@Part("photo\"; filename=\"image.png") RequestBody head);

    /**
     * 获取帮付数据
     * @param token
     * @param orderNo
     * @return
     */
    @GET("pay/helpPay")
    Observable<BaseResult<PayBean>> helpPay(@Header("Authorization") String token, @Query("orderNo")String orderNo);

    /**
     * 获取消息列表
     * @param token
     * @param carrierId
     * @return
     */
    @GET("carrier/message/{carrierId}")
    Observable<BaseResult<List<NewsBean>>> getNews(@Header("Authorization") String token,@Path("carrierId")String carrierId);

    /**
     * 获取学习视频地址
     * @param token
     * @param chapter
     * @return
     */
    @GET("carrier/exams/resource/{chapter}")
    Observable<BaseResult<ResourceUrlBean>> getExamResource(@Header("Authorization") String token,@Path("chapter")int chapter);

    @GET("carrier/locations/k_chart")
    Observable<BaseResult<List<HotMapBean>>> getHotMap(@Header("Authorization") String token,@Query("cityName")String cityName,@Query("day")int day);
}
